import request from '../utils/request/SpnRequest'
import { shopData } from './shopcart/cart'

export interface orderDetailData{
    id: null,
    orderId: null,
    skuId: number,
    skuName: string,
    imgUrl: string,
    orderPrice: number,
    skuNum: number,
    hasStock: null
}
export type tradeInfoData={
    tradeNo:number
    consignee:string
    consigneeTel:string
    deliveryAddress:string
    paymentWay:string
    orderComment:string
    orderDetailList:orderDetailData[]
}

export interface shopcartListData{
    activityRuleList:null
    cartInfoList: shopData[]
    createTime: string
}
/**
 * 获取交易页购买商品列表信息
 * @returns promise
 */
export const ReqTrade =()=> request.get<any,shopData[]>('/api/order/auth/trade')
/**
 * 提交订单 获取支付信息
 * @param tradeNo 
 * @param data 
 * @returns 
 */
export const reqOrder =(tradeNo:number,data:tradeInfoData)=> request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,data)

/**
 * 获取订单支付信息
 * @param orderId 
 * @returns 
 */
export const reqPay =(orderId:number)=> request.get<any,null>(`/api/payment/weixin/createNative/${orderId}`)

/**
 * 获取支付状态
 * @param orderId 
 * @returns 
 */
export const reqPayStatus=(orderId:number)=> request.get<any,null>(`/api/payment/weixin/queryPayStatus/${orderId}`)